import './reset.css'
import './style.css'
import { editor } from './editor/editor/editor-core';
import ResourceServiceManager from './editor/server/resouce-service.manager';
import { DslAtomicType, DslConstType, DslStructType, DslUnionType } from './editor/type-server/type-definition';

const httpMethod = new DslUnionType();
httpMethod
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'GET'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'POST'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'PUT'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'DELETE'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'PATCH'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'HEAD'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'OPTIONS'));
const serverType = new DslUnionType();
serverType
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'test'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'prod'))
    .union(new DslConstType(DslAtomicType.STRING_TYPE, 'dev'))
    .union(DslAtomicType.STRING_TYPE);

const pathType = DslAtomicType.STRING_TYPE;

const rootType = new DslStructType('postman');
rootType.require('method', httpMethod, 'GET');
rootType.require('server', serverType, 'test');
rootType.require('path', pathType);

// 创建一个 JsonTokenService 实例
const tokenService = new ResourceServiceManager(resourceId => {
    // 为每个资源ID创建一个 SchemaResourceService 实例
});
// 获取页面上的容器元素
const container = document.getElementById('app');
if (container) {
    // 调用 editor 函数并将编辑器挂载到容器上
    editor(tokenService, container).catch(console.error);
}
